package com.atguigu.srb.core.service.impl;

import com.atguigu.PageEntity;
import com.atguigu.Result;
import com.atguigu.srb.core.entity.IntegralGrade;
import com.atguigu.srb.core.mapper.IntegralGradeMapper;
import com.atguigu.srb.core.service.IntegralGradeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 积分等级表 服务实现类
 * </p>
 *
 * @author ccy
 * @since 2025-04-09
 */
@Service
public class IntegralGradeServiceImpl extends ServiceImpl<IntegralGradeMapper, IntegralGrade> implements IntegralGradeService {


    /**
     * 删除逻辑 - 未删除
     */
    private static final Integer NO_DELETE = 0;

    /**
     * 删除逻辑 - 已删除
     */
    private static final Integer YES_DELETE = 1;

    @Resource
    private IntegralGradeService integralGradeService;



    @Override
    public IPage<IntegralGrade> selectByPage(PageEntity<IntegralGrade> pageEntity) {

        IntegralGrade entity = pageEntity.getEntity();

        Page<IntegralGrade> page = new Page<>(pageEntity.getPageNo(), pageEntity.getPageSize());
        LambdaQueryWrapper<IntegralGrade> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(IntegralGrade::getDeleted, NO_DELETE);
        Page<IntegralGrade> iPage = this.page(page, queryWrapper);

        return iPage;

    }

    @Override
    public Result<?> deleteByIds(List<String> ids) {

        return Result.setSucMsg("删除成功!", integralGradeService.removeByIds(ids));
    }
}
